package top.lixb.libcommon.utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

import com.vondear.rxtool.RxTool;

public class SPUtils {
	public static SharedPreferences mSp;
	public static Editor mEditor;
	static {
		mSp = RxTool.getContext().getSharedPreferences(
				RxTool.getContext().getPackageName()
				, Context.MODE_PRIVATE);
		mEditor = mSp.edit();
	}

	public static void clear() {
		mEditor.clear().commit();
		boolean commit = mSp.edit().clear().commit();
	}

	/**取出string*/
	public static String getString(String key, String defValue) {
		return mSp.getString(key, defValue);
	}

	/**取出string*/
	public static long getLong(String key, long defValue) {
		return mSp.getLong(key, defValue);
	}

	/**取出int*/
	public static int getInt(String key, int defValue) {
		return mSp.getInt(key, defValue);
	}

	/**存入string*/
	public static void putLong(String key, long value) {
		mEditor.putLong(key, value);
		mEditor.commit();
	}


	/**取出boolean*/
	public static boolean getBoolean(String key, boolean defValue) {
		return mSp.getBoolean(key, defValue);
	}

	/**存入string*/
	public static void putString(String key, String value) {
		mEditor.putString(key, value);
		mEditor.commit();
	}

	/**存入int*/
	public static void putInt(String key, int value) {
		mEditor.putInt(key, value);
		mEditor.commit();
	}

	/**存入boolean*/
	public static void putBoolean(String key, boolean value) {
		mEditor.putBoolean(key, value);
		mEditor.commit();
	}



}
